package com.start_eternity.oasissafewalk.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.start_eternity.oasissafewalk.mapper.FeedBackMapper;
import com.start_eternity.oasissafewalk.pojo.FeedBack;
import com.start_eternity.oasissafewalk.pojo.Order;
import com.start_eternity.oasissafewalk.pojo.PageBean;
import com.start_eternity.oasissafewalk.service.FeedBackService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * author:ZhangT
 * Date:2024 / 03 / 10 / 17:30
 * Description:
 */
@Service
public class FeedBackServiceImpl implements FeedBackService {

    @Resource
    private FeedBackMapper feedBackMapper;
    @Override
    public List<FeedBack> findAll() {
        List<FeedBack> feedBacks = feedBackMapper.queryList();
        return feedBacks;
    }

    @Override
    public int delBatchId(List<Integer> nId) {
        int rows = feedBackMapper.deleteBachId(nId);
        return rows;
    }

    @Override
    public int insert(FeedBack feedBack) {
        int rows = feedBackMapper.insert(feedBack);
        return rows;
    }

    @Override
    public PageBean queryPage(int page, int pageSize) {
        //1.设置分页参数
        PageHelper.startPage(page,pageSize);

        //2.执行查询
        List<FeedBack> feedBacks = feedBackMapper.queryPage(page, pageSize);
        Page<FeedBack> p = (Page<FeedBack>) feedBacks;
        //3.封装PageBean对象
        return new PageBean(p.getTotal(),p.getResult());
    }

}
